﻿@model IEnumerable<HanGu.Entity.MemberInfo>
@{
    Layout = null;
    int i = 1;
    ViewBag.ViewTitle = "会员";
    var SearchParma = ViewData["SearchParma"] as HanGu.Entity.UniversallySearchParam;
    var MemberGrade = ViewData["MemberGrade"] as SelectList;
    var Degree = ViewData["Degree"] as SelectList;
    var SexList = ViewData["SexList"] as SelectList;
    string lookup = Request["lookup"];
    string formCallback = "navTabSearch(this)";
    if (!string.IsNullOrEmpty(lookup))
    {
        formCallback = "dwzSearch(this, 'dialog')";
    }
    
}
<form id="pagerForm" method="get" action="/admin/@ViewData["CurrentController"]/index">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
<input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
<input type="hidden" name="orderField" value="${param.orderField}" />
<input type="hidden" name="Title" value="@SearchParma.Ttile" />
<input type="hidden" name="Suitabler" value="@SearchParma.Suitabler" />
<input type="hidden" name="Lectcher" value="@SearchParma.Lectcher" />
<input type="hidden" name="PalayAdress" value="@SearchParma.PalayAdress" />
<input type="hidden" name="Degree" value="@SearchParma.Degree" />
<input type="hidden" name="StarTime" value="@SearchParma.StarDateTime" />
<input type="hidden" name="EndTime" value="@SearchParma.EndDateTime" />
<input type="hidden" name="lookup" value="@lookup" />

</form>
<script>
    $(function () { 
    $("#Form_@ViewData["CurrentController"] #Lectcher").val("@SearchParma.Lectcher");
    $("#Form_@ViewData["CurrentController"] #Degree").val("@SearchParma.Degree");
    });
</script>
<div class="pageHeader">
    <form onsubmit="return @formCallback;" id="Form_@ViewData["CurrentController"]" action="/admin/@ViewData["CurrentController"]/index"
    method="post">
    <input type="hidden" name="lookup" value="@lookup" />
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>
                    姓名：
                </td>
                <td>
                    @Html.TextBox("Title", SearchParma.Ttile)
                </td>
                <td>
                    账号：
                </td>
                <td>
                    @Html.TextBox("Suitabler", SearchParma.Suitabler)
                </td>
                <td>
                    级别：
                </td>
                <td>
                    @Html.DropDownList("Lectcher", MemberGrade, new { @class = "combox" })
                </td>
            </tr>
            <tr>
                <td>
                    开通时间：
                </td>
                <td>
                    <p>
                        @Html.TextBox("StarTime", SearchParma.StarDateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
                    </p>
                </td>
                <td>
                    ~
                </td>
                <td>
                    <p>
                        @Html.TextBox("EndTime", SearchParma.EndDateTime, new { @class = "date", format = "yyyy-MM-dd HH:mm", @readonly = "true" })
                    </p>
                </td>
                <td>
                    学位：
                </td>
                <td>
                    @Html.DropDownList("Degree", Degree, new { @class = "combox" })
                </td>
                <td align="right">
                    <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="submit" name="submit">
                                            检索</button></div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            @if (string.IsNullOrEmpty(lookup))
            {
                 <li><a class="icon" href="admin/@ViewData["CurrentController"]/Detail/{@ViewData["CurrentController"]_id}?action=edit" target="navTab" warn="请选择一个用户" title="查看-@ViewBag.ViewTitle">
                    <span>查看</span></a></li>
                <li><a class="add" href="admin/@ViewData["CurrentController"]/Create/0?action=add" target="navTab" title="添加-@ViewBag.ViewTitle">
                    <span>添加</span></a></li>
                <li><a class="edit" href="admin/@ViewData["CurrentController"]/Create/{@ViewData["CurrentController"]_id}?action=edit" target="navTab" warn="请选择一个用户" title="修改-@ViewBag.ViewTitle">
                    <span>修改</span></a></li>
                <li><a class="delete" href="admin/@ViewData["CurrentController"]/Delete/{@ViewData["CurrentController"]_id}" target="ajaxTodo" title="确定要删除吗？" warn="请选择一个用户">
                    <span>删除</span></a></li>
                <li><a class="icon" href="admin/@ViewData["CurrentController"]/ResetPWD/{@ViewData["CurrentController"]_id}" target="ajaxTodo" title="确定要重设置密码吗？" warn="请选择一个用户">
                    <span>重设密码</span></a></li>
                
                <li><a class="add" title="发送邮件" warn="请选择一个用户" onclick="SendEmail(this);return false;">
                    <span>发送邮件</span></a></li>
                <li><a class="add" onclick="SendSMS(this);return false;"><span>发送短信</span></a></li>
                <li><a class="add" href="admin/ChangeGradeRecorde/Index/{@ViewData["CurrentController"]_id}" target="navTab" rel="ChangeGradeRecorde" title="学位记录" warn="请选择一个用户">
                    <span>学位记录</span></a></li>
                <li><a class="add" href="admin/ChangeGradeRecorde/Create/{@ViewData["CurrentController"]_id}" target="navTab" title="升级学位" rel="ChangeGradeRecordeAdd" warn="请选择一个用户">
                    <span>升级学位</span></a></li>
                <li><a class="add" href="admin/ChangeChargeRecorde/Index/{@ViewData["CurrentController"]_id}" target="navTab" rel="ChangeChargeRecorde"  title="充值记录" warn="请选择一个用户">
                    <span>充值记录</span></a></li>
                <li><a class="add" href="admin/ChangeChargeRecorde/Create/{@ViewData["CurrentController"]_id}" target="navTab" title="充值" rel="ChangeChargeRecordeAdd" warn="请选择一个用户">
                    <span>充值</span></a></li>
                <li><a class="add" href="admin/ChargeRecorde/Index/{@ViewData["CurrentController"]_id}" target="navTab" title="消费记录" rel="ChargeRecorde" warn="请选择一个用户">
                    <span>消费记录</span></a></li>
                <li><a class="add" href="admin/ChargeRecorde/Create/{@ViewData["CurrentController"]_id}" target="navTab" title="消费" rel="ChargeRecordeAdd" warn="请选择一个用户">
                    <span>消费</span></a></li>
            }
            else
            { 
                <li style="height:30px;">
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" multLookup="@lookup" warn="请选择会员">
                                确定选择</button></div>
                    </div>
                </li>
            }
        </ul>
        <script>
            SendSMS = function (obj) {
                $this = $(obj);
                var member = $("#memberItem.selected");
                if (member.attr("rel") == undefined) {
                    alertMsg.error("请选择一条会员记录"); return false;
                }
                var isSms = member.attr("nosms");
                if (isSms != undefined) {
                    navTab.openTab("SendSMS", "admin/Message/SMS/0" + "?memberid=" + member.attr("itemID") + "&reciever=" + member.attr("tel"), { title: "发送信息", fresh: true });
                }
                else {
                    alertMsg.error("此会员设置不接收信息");
                }
                return false;
            }
            SendEmail = function (obj) {
                $this = $(obj);
                var member = $("#memberItem.selected");
                if (member.attr("rel") == undefined) {
                    alertMsg.error("请选择一条会员记录"); return false;
                }
                var isSms = member.attr("noemail");
                if (isSms != undefined) {
                    navTab.openTab("SendEmail", "admin/Message/Email/0" + "?memberid=" + member.attr("itemID") + "&reciever=" + member.attr("email"), { title: "发送邮件", fresh: true });
                }
                else {
                    alertMsg.error("此会员设置不接收邮件");
                }
                return false;
            }
        </script>
    </div>
    <table class="table" width="100%" layouth="170">
        <thead>
            <tr class="header">
                @if (!string.IsNullOrEmpty(lookup))
                {
                    <th>
                        <input type="checkbox" class="checkboxCtrl" group="@lookup" />选择
                    </th>
                }
                <th style="width: 50px">
                    序号
                </th>
                <th>
                    姓名(账号)
                </th>
                <th>
                    性别
                </th>
                <th>
                    学位
                </th>
                <th>
                    级别
                </th>
                <th>
                    积分
                </th>
                <th>
                    电话
                </th>
                <th>
                    关联人
                </th>
                <th>
                    注册时间
                </th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {            
            <tr id="memberItem" target="@ViewData["CurrentController"]_id" rel="@item.ID/@item.GUID" itemID="@item.ID" nosms="@item.NoSMS" noemail="@item.NoEmail" tel="@item.Tel" email="@item.Email" >
                @if (!string.IsNullOrEmpty(lookup))
                {
                    string receiver = string.Empty;
                    if (lookup == "SMS")
                    {
                        receiver = item.Tel;
                    }
                    else
                    {
                        receiver = item.Email;
                    }
                     
                    <td>
                        <input  type="checkbox" name="@lookup" value="{MemberID:'@item.ID', Receiver:'@receiver',Username:'@item.UserName'}"/>
                    </td>
                }
                <td>
                    @i
                </td>
                <td>
                    @item.RealName
                    (@item.UserName)
                </td>
                <td>
                    @{
                var modelsex = SexList.SingleOrDefault(c => c.Value == item.Sex);
                if (modelsex != null)
                {
                        @modelsex.Text
                }
                    }
                </td>
                <td>
                    @{
                var modelDegree = Degree.SingleOrDefault(c => c.Value == item.Degree);
                if (modelDegree != null)
                {
                        @modelDegree.Text
                }   
                    }
                </td>
                <td>
                    @{
                var modelGrade = MemberGrade.SingleOrDefault(c => c.Value == item.Grade);
                if (modelGrade != null)
                { 
                        @modelGrade.Text;
                }
                    }
                </td>
                <td>
                    @item.Charge
                </td>
                <td>
                    @item.Tel
                </td>
                <td>
                    @item.RelationMem
                </td>
                <td>
                    <span formatdate="yyyy-MM-dd HH:mm">
                        @item.CreateTime</span>
                </td>
            </tr>
                i += 1;
        }
    </table>
</div>
<div class="panelBar">
    <div class="pages">
        <span>共【@ViewData["RowCount"] 】条,每页显示【@ViewData["pageSize"] 】条</span>
    </div>
    <div class="pagination" targettype="navTab" totalcount="@ViewData["RowCount"] "
            numperpage="@ViewData["pageSize"] " pagenumshown="10" currentpage="@Request["pageNum"] ">
    </div>
</div>
